package com.yanqu.road.server.cmd.unioncampwar;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.unionCampWar.UnionCampWar;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.unioncampwar.CrossUnionCampWarMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C3_UNION_CAMP_WAR_ATTACK_TEAM, desc = "商帮进攻")
public class CrossUnionCampWarAttackCmd extends CrossCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        UnionCampWar.CrossUnionCampWarAttackReqMsg reqMsg = UnionCampWar.CrossUnionCampWarAttackReqMsg.parseFrom(packet.getBytes());
        ret = CrossUnionCampWarMgr.attackHold(packet.getPlayerId(), serverId, reqMsg);
        if (ret != 0) {
            MessageHelper.sendPacket(serverId, packet.getPlayerId(),
                    YanQuMessageUtils.buildMessage(GameProtocol.S_UNION_CAMP_WAR_ATTACK_TEAM_CROSS_BACK,
                            UnionCampWar.UnionCampWarAttackRespMsg.newBuilder().setRet(ret)));
        }
    }

    @Override
    public void sendData() {
    }
}
